package com.taoyi.mhouse.fragments;

import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import java.util.Random;

/**
 * @author tempo
 *         on 2015/11/23.
 */
public class FindingFragment extends LoadingFreshingFragment<String> {
    Handler handler=new Handler();
    private String  data;

    @Override
    public void loadData(final LoadingCallback callback) {
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Random rand = new Random();
                int i= rand.nextInt(2);
                if(i==0){
                    data="success....guanbalei";
                    callback.setResult(ResultState.Success,data);
                }else if(i==1){
                    callback.setResult(ResultState.Error,null);
                }else{
                    callback.setResult(ResultState.Empty,null);
                }

            }
        },1500);
    }

    @Override
    public View getSuccessView(View parent, String data) {
        TextView tv=new TextView(getContext());
        tv.setTextSize(44);
        tv.setText(data);
        return tv;
    }



    @Override
    protected void clearData() {
        data=null;
    }
}
